package com.ibm.crl.sb.thread.others.atomic;

import java.util.concurrent.atomic.AtomicInteger;

public class AtomicIntegerTest {

	private AtomicInteger times1 = new AtomicInteger(0);

	 private int times2 = 0;

	public AtomicIntegerTest() {
		Thread[] threads = new Thread[10];
		for (int i = 0; i < 10; i++) {
			threads[i] = new Thread(run);
			threads[i].start();
		}
	}

	Runnable run = new Runnable() {

		@Override
		public void run() {
			while (true) {
				 System.out.println("times2:" + times2++);
//				System.out.println("times1:" + times1.incrementAndGet());
				System.out.println("===============");
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	};

	public static void main(String[] args) {
		new AtomicIntegerTest();
	}
}
